package com.pzb.framework.web.service;

import com.pzb.common.core.domain.model.LoginUser;
import com.pzb.common.core.domain.model.WechatUser;
import com.pzb.common.core.redis.RedisCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 登录校验方法
 * 
 * @author pzb
 */
@Component
public class SysLoginService
{
    @Autowired
    private TokenService tokenService;

    @Resource
    private AuthenticationManager authenticationManager;

    @Autowired
    private RedisCache redisCache;


    /**
     * 登录验证
     *
     * @return 结果
     */
    public String login(WechatUser user)
    {
        LoginUser loginUser = new LoginUser(user.getOpenid(),user);
        // 生成token
        return tokenService.createToken(loginUser);
    }



}
